package com.ryan.security.validator;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * Created by kaimin on 31/12/2018.
 * time : 23:33
 */
//MyValidator 自己的  String参数类型
public class MyConstraintValidator implements ConstraintValidator<MyValidator,Object> {
    //这个方法也可以注入自己的service

    @Override
    public void initialize(MyValidator constraintAnnotation) {
        System.out.println("完成自己注解的初始化");
    }

    @Override
    public boolean isValid(Object value, ConstraintValidatorContext context) {
        //真正的校验逻辑
        System.out.println("value:"+value);
        return true;
    }
}
